package composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: Ma JiBin
 * @Email: 1423553596@qq.com
 * @Date: 2018/9/7 11:04
 * @Description: 员工类
 * name: 姓名
 * dept: 职位
 * salary: 薪水
 * subordinates：下级员工列表
 */
public class Employee {
    private String name;
    private String dept;
    private int salary;
    private List<Employee> subordinates;

    public Employee(String name, String dept, int salrry) {
        this.name = name;
        this.dept = dept;
        this.salary = salrry;
        subordinates = new ArrayList<Employee>();
    }

    public void add(Employee e) {
        subordinates.add(e);
    }

    public void remove(Employee e) {
        subordinates.remove(e);
    }

    public List<Employee> getSubordinates() {
        return subordinates;
    }


    @Override
    public String toString() {
        return "Employee: [ Name : " + name
                + ",dept : " + dept
                + ",salary : " + salary + "]";
    }
}
